#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QKeyEvent>
#include <QPaintEvent>

namespace Ui {
class Widget;
}

class Widget : public QWidget
{
    Q_OBJECT

public:
    explicit Widget(QWidget *parent = 0);
    ~Widget();

    void drawPix();
    void keyPressEvent(QKeyEvent *event);
    void paintEvent(QPaintEvent *event);

private:
    Ui::Widget *ui;

    QPixmap *pix; // 双缓冲绘制
    QImage image;
    int startX, startY; // 图标左上角坐标
    int width, height; // 界面宽高
    int stepX, stepY; // 网格大小，每次移动一个网格
};

#endif // WIDGET_H
